package org.spolo.android.shape;

import org.spolo.android.nodetree.Vcanvas;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

public class Hotpoint extends Vcanvas {

	protected float x;
	protected float y;
	protected float radius;
	private Paint hpaint = new Paint();
	private int flag;

	/**
	 * @param x
	 *            圆心X坐标
	 * @param y
	 *            圆心Y坐标
	 * @param radius
	 *            半径
	 */
	public Hotpoint(float x, float y, float radius) {
		super();
		this.zIndex = 1;
		this.x = x;
		this.y = y;
		this.radius = radius;
		this.hpaint.setColor(Color.RED);
		this.hpaint.setAlpha(100);
		this.flag = 0;
		setDirtyRect((x - radius - 5), (y - radius - 5), (radius + 5) * 2,
				(radius + 5) * 2);
	}

	@Override
	public void drawSelfImplement(Canvas canvas) {
		this.drawHotpoint(x, y, radius, canvas);
	}

	private void drawHotpoint(float x_orig, float y_orig, float radius,
			Canvas canvas) {
		if (flag == 0) {
			this.radius += 10;
			flag = 1;
		} else {
			this.radius -= 10;
			flag = 0;
		}
		canvas.drawCircle(x, y, radius, this.hpaint);
	}
}
